package com.pswv2.backstage.skyset.imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pswv2.backstage.skyset.service.SkySetService;
import com.pswv2.bub.bsc.dao.po.Details;
import com.pswv2.bub.bsc.dao.po.KWord;
import com.pswv2.util.ExtraSpringHibernateTemplate;

@Service
public class SkySetServiceImp implements SkySetService {
	private static Class<?> poc = KWord.class;
	private static Class<?> poc1 = Details.class;
	@Autowired
	private ExtraSpringHibernateTemplate extraSpringHibernateTemplate;

	@Override
	public List<KWord> queryByKWord(String kword) {
		List<KWord> roles=(List<KWord>) extraSpringHibernateTemplate.getHibernateTemplate().find("From KWord where kwords like ? ", '%' +kword+'%' );
		return roles;
	}

	@Override
	public Details queryById(int id) {
		// TODO Auto-generated method stub
		return  extraSpringHibernateTemplate.findFirstOneByPropEq(poc1, "detailsId", id);
	}
	@Override
	public List<KWord> queryAllUser(int userId) {
		// TODO Auto-generated method stub
		return (List<KWord>) extraSpringHibernateTemplate.getHibernateTemplate().find("From KWord where userId=?",userId);
	}
}
